package com.cskaoyan.service;

import com.cskaoyan.domain.MarketSystem;
import com.cskaoyan.mapper.MarketSystemMapper;
import com.github.pagehelper.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

@Service
public class SystemServiceImpl implements SystemService{
    @Autowired
    MarketSystemMapper systemMapper;

    @Override
    public Integer selectIntegerValueById(Integer id) {
        MarketSystem system = systemMapper.selectByPrimaryKey(id);
        String keyValue = system.getKeyValue();
        return StringUtil.isEmpty(keyValue) ? null : Integer.parseInt(keyValue);
    }

    @Override
    public String selectStringValueById(Integer id) {
        MarketSystem system = systemMapper.selectByPrimaryKey(id);
        return system.getKeyValue();
    }

    @Override
    public BigDecimal selectBigDecimalValueById(Integer id) {
        MarketSystem system = systemMapper.selectByPrimaryKey(id);
        String keyValue = system.getKeyValue();
        return new BigDecimal(keyValue);
    }
}
